package Array;

import javax.imageio.stream.ImageInputStream;

public class item48 {
    public static void rotate(int[][] matrix) {
        int row = matrix.length;
        int col = matrix[0].length;
        for (int i = 0; i <row ; i++) {
            for (int j = 0; j < i; j++) {
                if(i==j)
                    continue;
                else
                {
                    int temp = matrix[i][j];
                    matrix[i][j]=matrix[j][i];
                    matrix[j][i] = temp;
                }
            }
        }
        for (int i = 0; i <row ; i++) {
           int start = 0;
           int end =matrix[0].length-1;
           while (start<end)
           {
               int temp = matrix[i][start];
               matrix[i][start]=matrix[i][end];
               matrix[i][end]= temp;
               start++;
               end --;
           }
        }

    }

    public static void main(String[] args) {
        int [][]num={
                {1,2,3},{4,5,6},{7,8,9}
        };
        rotate(num);
    }
}
